﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

using VLUNewsData.EntityDataModel;
using System.Data.Objects;
using VLUNewsBusiness.Utilities;

namespace VLUNewsBusiness.VLURolesAndUsers
{
    public class RoleAndUser
    {
        public static int GetNewsRoleGroupID()
        {
            int result = -1;
            using (VLUNewsEntities ent = new VLUNewsEntities())
            {
                ObjectResult<string> oObjectResult = ent.ExecuteStoreQuery<string>(String.Format(SqlString.getNewsRoleGroup, BaseSettings.NewsRoleGroupName));
                result = int.Parse(oObjectResult.First());
            }
            //return result == string.Empty ? -1 : int.Parse(result);
            return result;
        }

        public static void UpdateNewsRoleGroupID(int pRoleGroupID, int pUserID)
        {
            using (VLUNewsEntities ent = new VLUNewsEntities())
            {
                int result = ent.ExecuteStoreCommand(SqlString.updateNewsRoleGroup, BaseSettings.NewsRoleGroupName, pRoleGroupID, pUserID, DateTime.Now);
            }
        }
    }
}
